﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PMS.ENT;
using PMS.DAL;

namespace PMS.BLL
{
    public class ProjectBLL
    {
        #region Get
        public static ProjectENT GetProjectByID(int projectID)
        {
            try
            {
                return ProjectDAL.GetProjectByID(projectID);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static ProjectENT GetProjectBySemesterID(int projectID, int semesterID)
        {
            try
            {
                return ProjectDAL.GetProjectBySemesterID(projectID, semesterID);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static ProjectENT GetProjectByScheduleGroupID(int scheduleGroupID)
        {
            try
            {
                return ProjectDAL.GetProjectByScheduleGroupID(scheduleGroupID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static ProjectCollection GetProjectListBySubjectID(int subjectID)
        {
            try
            {
                return ProjectDAL.GetProjectListBySubjectID(subjectID);
            }
            catch (Exception)
            {

                throw;
            }
        }


        public static ProjectCollection GetProjectList(string projectName, int semesterID, int userID, int departmentID, int subjectID, string status, string orderBy, string orderDirection, int page, int pageSize, out int totalRecords)
        {
            try
            {
                return ProjectDAL.GetProjectList(projectName, semesterID, userID, departmentID, subjectID, status, orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static ProjectCollection GetProjectList(string projectName, int departmentID, int subjectID, string orderBy, string orderDirection, int page, int pageSize, out int totalRecords)
        {
            try
            {
                return ProjectDAL.GetProjectList(projectName, departmentID, subjectID, orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (Exception)
            {
                throw;
            }
        }


    

        public static ProjectCollection GetProjectListForCMB(int userID)
        {
            try
            {
                ProjectCollection listProject = new ProjectCollection();
                listProject.Add(new ProjectENT { ProjectID = 0, ProjectName = "--All--" });
                listProject.AddRange(ProjectDAL.GetProjectListForCMB(userID));
                return listProject;
            }
            catch (Exception)
            {

                throw;
            }


        }

        public static StudentProjectCollection GetStudentProjectList(int semesterID, int departmentID, int subjectID)
        {
            try
            {
                return ProjectDAL.GetStudentProjectList(semesterID, departmentID, subjectID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static StudentProjectCollection GetStudentList(int semesterID, int departmentID, int subjectID)
        {
            try
            {
                return ProjectDAL.GetStudentList(semesterID, departmentID, subjectID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static ProjectCollection GetProjectList(int semesterID, int departmentID, int subjectID)
        {
            try
            {
                return ProjectDAL.GetProjectList(semesterID, departmentID, subjectID);
            }
            catch (Exception)
            {
                throw;
            }
        }

        #endregion

        #region Insert Update Delete Confirm

        public static int InsertProject(ProjectENT project)
        {
            try
            {
                return ProjectDAL.InsertProject(project);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int UpdateProject(ProjectENT project)
        {
            try
            {
                return ProjectDAL.UpdateProject(project);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int DeleteProject(string projectID, int userID)
        {
            try
            {
                return ProjectDAL.DeleteProject(projectID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int ConfirmProject(string projectID, int userID)
        {
            try
            {
                return ProjectDAL.ConfirmProject(projectID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int JoinProject(int projectID, int groupID, int userID, int semesterID)
        {
            try
            {
                return ProjectDAL.JoinProject(projectID, groupID, userID, semesterID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int UnJoinProject(int projectID, int groupID, int userID, int semesterID)
        {
            try
            {
                return ProjectDAL.UnJoinProject(projectID, groupID, userID, semesterID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        #endregion

        #region Validate

        public static bool CheckIsOwnAndDraft(int[] projectID, int userID)
        {
            try
            {
                return ProjectDAL.CheckIsOwnAndDraft(projectID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static bool CheckIsOwn(int[] projectID, int userID)
        {
            try
            {
                return ProjectDAL.CheckIsOwn(projectID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static bool CheckProjectStatus(int[] projectID, string status)
        {
            try
            {
                return ProjectDAL.CheckProjectStatus(projectID, status);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int CheckIsJoin(int projectID, int userID, int semesterID)
        {

            try
            {
                return ProjectDAL.CheckIsJoin(projectID, userID, semesterID);
            }
            catch (Exception)
            {

                throw;
            }
        }
        #endregion
    }
}
